import request from '@/utils/request'

// 查询产品列表
export function getList (data) {
  return request({
    url: '/product/getList',
    method: 'post',
    data: data,
    headers: {
      'Content-Type': 'application/json',
      // 'Content-Type': 'application/x-www-form-urlencoded',
      'Authorization': window.localStorage.getItem('token'),
    }
  })
}

// 新增产品
export function addProduct (data) {
  return request({
    url: '/product/add',
    method: 'post',
    data: data,
    headers: {
      'Content-Type': 'application/json',
      'Authorization': window.localStorage.getItem('token'),
    }
  })
}

// 查看产品详情
export function lookDetail (data) {
  return request({
    url: '/product/getOne',
    method: 'get',
    params: data,
    headers: {
      // 'Content-Type': 'application/json',
      'Content-Type': 'application/x-www-form-urlencoded',
      'Authorization': window.localStorage.getItem('token'),
    }
  })
}

// 删除产品
export function deleteProduct (data) {
  return request({
    url: '/product/del',
    method: 'post',
    data: data,
    headers: {
      'Content-Type': 'application/json',
      'Authorization': window.localStorage.getItem('token'),
    }
  })
}


// 编辑产品
export function changeProduct (data) {
  return request({
    url: '/product/update',
    method: 'post',
    data: data,
    headers: {
      'Content-Type': 'application/json',
      'Authorization': window.localStorage.getItem('token'),
    }
  })
}

// 新增设备
export function addDevice (data) {
  return request({
    url: '/device/addDevice',
    method: 'post',
    data: data,
    headers: {
      'Content-Type': 'application/json',
      'Authorization': window.localStorage.getItem('token'),
    }
  })
}

// 消息订阅
export function addMessage (data) {
  return request({
    url: '/subscription/add',
    method: 'post',
    data: data,
    headers: {
      'Content-Type': 'application/json',
      'Authorization': window.localStorage.getItem('token'),
    }
  })
}

// 消息订阅历史
export function messageList (data) {
  return request({
    url: '/subscription/getList',
    method: 'post',
    data: data,
    headers: {
      'Content-Type': 'application/json',
      'Authorization': window.localStorage.getItem('token'),
    }
  })
}

// 删除消息订阅
export function removeMessage (data) {
  return request({
    url: '/subscription/del',
    method: 'post',
    data: data,
    headers: {
      'Content-Type': 'application/json',
      'Authorization': window.localStorage.getItem('token'),
    }
  })
}

